package com.lizi.core.java.thread;

public class Thread1 {

	
	/**
	 * get 没有枷锁的情况下，多执行几次结果都不一样
	 * @param args
	 */
	public static void main(String[] args) {
		Thread1 t = new Thread1(); 
		
		
		Thread threadA = new Thread(new Runnable() {
			
			@Override
			public void run() {
				String value = t.get();
				System.out.println(value);
			}
		});
		Thread threadB = new Thread(new Runnable() {
			
			@Override
			public void run() {
				t.put("111111111");
				System.out.println("end");
			}
		});
		
		Thread threadC = new Thread(new Runnable() {
			
			@Override
			public void run() {
				String value = t.get();
				System.out.println(value);
			}
		});
		
		threadA.start();
		threadB.start();
		threadC.start();
	}
	
	
	private String message = "111";
	public synchronized void put(String value){
		message = value;
		
	}
	
	public   String get(){
		return message;
	}
}
